<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<view class="head" :style="{ paddingTop: navBarHeight }">
			<view class="head-np">
				<view class="back" @click="back()">
					<image src="../../static/img/chat-09.png"></image>
				</view>
				<view class="title">{{ title }}记录</view>
				<view></view>
			</view>
		</view>
<!-- :style="{ paddingTop: navBarHeight }" -->
		<view class="main" v-if="type==19">
			<view class="item item2" v-for="item in list" @click="details()">
				<image src="@/static/img/extractive.png" mode=""></image>
				<view>
					<!-- <view class="text_1">USDT提现</view> -->
					<view>商品名称：{{ item.goodsName }}</view>
					<view class="text_2">兑换账号：{{ item.phone }}</view>
					<view class="text_2">{{item.createdTime}}</view>
					<text class="firend">{{item.orderNo}}</text>
				</view>
				<view v-if="type==19" class="item_s">
					<view>-{{item.price}}USDA</view>
					<view class="">{{item.isHandle==0?'待兑换':item.isHandle==1?'已兑换':'驳回'}}</view>
				</view>
				<view v-else class="item_p">-{{item.price}}USDA</view>
			</view>
			<view v-if="list.length<1" class="not">暂无数据~</view>
		</view>
		<view class="main" v-else>
			<view class="item" v-for="item in list" @click="details()">
				<image src="@/static/img/extractive.png" mode=""></image>
				<view>
					<!-- <view class="text_1">USDT提现</view> -->
					<view>
					{{ item.description }}
					<text v-if="item.description=='好友转账'" class="firend">（ID:{{item.transactionNo}})</text>
					</view>
					<view class="text_2">{{item.created}}</view>
					<text v-if="item.description=='兑换商品'" class="firend">订单编号：{{item.transactionNo}}</text>
				</view>
				<view> {{ item.type!=17? handleSign(item.mathSign) : ''}} {{item.amount}}</view>
			</view>
			<view v-if="list.length<1" class="not">暂无数据~</view>
		</view>
	</view>
</template>

<script>
	import {fundRecord,exchangeGoodsGetOrderPage} from '@/api/api.js'
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		data() {
			return {
				page: 1,
				size: 10,
				title: '',
				tabIndex: 0,
				list: '',
				isAll: false,
				type: 14
			}
		},
		mixins: [navBarMixin],
		onLoad(option) {
			console.log(option.type)
			if(option.type == 1) {
				this.type ='3,5,14'
				this.record('3,5,14')
				this.title = 'CC'
			}else if(option.type == 2) {
				this.type ='7'
				this.record(7)
				this.title = 'ABT'
			}else if(option.type == 15) {
				this.type ='4,6,13,15,17,18'
				this.record('4,6,13,15,17')
				this.title = 'USDA'
			}else if(option.type == 19) {
				this.type ='19'
				this.getGoods();
				this.title = '兑换商品'
			}else if(option.type == 20) {
				this.type ='20'
				this.record(20)
				this.title = '积分'
			}else if(option.type == 21) {
				this.type ='2'
				this.record(2)
				this.title = '提现额度'
			}
			
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			getGoods() {
				exchangeGoodsGetOrderPage({pageNum:this.page,pageSize:this.size}).then(res=>{
					console.log(res);
					if(res.code==0) {
						var info = this.list
						if (this.page == 1) {
							this.list = res.data.records
						} else {
							this.list = info.concat(res.data.records)
						}
						this.isAll = this.list.length <10 ? false : true
					}
				})
			},
			record(type) {
				fundRecord({pageNum:this.page,pageSize:this.size, type: this.type}).then(res=>{
					console.log(res);
					if(res.code==0) {
						var info = this.list
						if (this.page == 1) {
							this.list = res.data.records
						} else {
							this.list = info.concat(res.data.records)
						}
						this.isAll = this.list.length <10 ? false : true
					}
				})
			},
			details() {
				// uni.navigateTo({
				// 	url:'/pages/me/rechargeDetails'
				// })
			},
			handleState(e) {
				const arr = ['提现中','提现成功','提现失败']
				return arr[e]
			},
			handleSign(e) {
				return e == 1 ? '+' : '-'
			}
		},
		onReachBottom() {
			console.log(this.isAll);
			if (this.isAll) {
				this.page++;
				this.record()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		overflow: hidden;

		.back {
			image {
				width: 20rpx;
				height: 37rpx;
			}
		}

		.head {
			position: fixed;
			top: 0;
			z-index: 333;
			width: 100%;
			background: #fff;

			.head-np {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 96rpx;
				padding: 0 30rpx;
				box-sizing: border-box;

				.title {
					font-size: 36rpx;
					font-weight: bold;
				}
			}
		}

		.main {
			// margin-top: 126rpx;
			margin-top: 30rpx;
			margin: 30rpx 30rpx 60rpx;
			padding: 0 30rpx 40rpx;
			background-color: white;
			border-radius: 10rpx;
			overflow: hidden;
			
			.item2 {
				height: 240rpx !important;
			}

			.item {
				height: 150rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #EEEEEE;

				image {
					width: 54rpx;
					height: 54rpx;
					margin-right: 20rpx;
				}

				>view {
					.text_1 {
						font-size: 30rpx;
						color: #333333;
						line-height: 42rpx;
					}
					.text_2 {
						height: 42rpx;
						font-size: 26rpx !important;
						font-weight: 400 !important;
						color: #999999;
						line-height: 42rpx;
						margin-top: 8rpx;
					}
					&:nth-of-type(1) {
						flex: 1;
					}
					
					&:nth-of-type(2) {
						font-weight: 500;
						font-size: 30rpx;
						color: #FF5B5B;
					}
				}
				.item_p {
					font-weight: 500;
					font-size: 30rpx;
					color: #FF5B5B;
				}
				.item_s {
					text-align: right;
					view:nth-of-type(1) {
						font-weight: 500;
						font-size: 30rpx;
						color: #FF5B5B;
					}
					view:nth-of-type(2) {
						// font-weight: 500;
						font-size: 28rpx;
						color: #3F93FF;
						margin-top: 20rpx;
					}
				}
			}
		}
	}
	.not {
		color: #999999;
		text-align: center;
		margin: 30rpx auto;
	}
	.firend {
		color: #999999;
		font-size: 24rpx
	}
</style>